// JavaScript Document

function exec_javascript(script) {
	eval(script);
}

function setColor(obj) {
	obj.style.color = '#0046d5';
	obj.style.textDecoration = 'underline';
}
function clrColor(obj) {
	obj.style.color = '#666666';
	obj.style.textDecoration = 'none';
}

function show(idObj) {
	var obj = document.getElementById(idObj);
	var btn = document.getElementById("title_" + idObj);
	var status = obj.style.visibility;
	// alert(func);
	switch (status) {
	case "hidden":
		obj.style.visibility = "visible";
		btn.innerHTML = "Ocultar";
		// setTimeout("xajax_"+func+"()",10);
		break;
	case "visible":
		obj.style.visibility = "hidden";
		obj.innerHTML = "";
		btn.innerHTML = "Desplegar";
		break;
	}

}

function str_replace(cadena, cambia_esto, por_esto) {
	return cadena.split(cambia_esto).join(por_esto);
}

function get_name_file(path) {
	// alert(path);
	var name_file = path.substring(path.lastIndexOf("\\"));
	var ext = name_file.substring(name_file.lastIndexOf("."));
	// alert(ext);
	name_file = name_file.substring(0, name_file.length - ext.length);
	name_file = name_file.replace("\\", "");
	return name_file;
}

function get_extension(path) {
	// alert(path);
	var name_file = path.substring(path.lastIndexOf("\\"));
	var ext = name_file.substring(name_file.lastIndexOf("."));
	// alert(ext);
	return ext;
}

function disable_select(h) {
	tag = document.getElementsByTagName('select');
	for (i = tag.length - 1; i >= 0; i--) {
		if (tag[i].title == 'search')
			tag[i].style.visibility = 'hidden';
	}
}
function my_submit(func, frm) {
	var str_cmd = "xajax_" + func + "(xajax.getFormValues('" + frm + "'));";
	eval(str_cmd);
	return false;
}

function change_value(id, new_value) {
	var obj = document.getElementById(id);
	if (obj) {
		obj.value = new_value;
		// alert(obj.value);
	}
}

function open_window(file_path, file_width, file_height) {
	// alert(path);
	if (!file_width) {
		file_width = 640;
	}
	if (!file_height) {
		file_height = 480;
	}
	file_left = (screen.availWidth - file_width) / 2;
	file_top = (screen.availHeight - file_height) / 2;
	var new_wind = window
			.open(
					file_path,
					"",
					"statusbar=no,menubar=no,locationbar=no,toolbar=no,scrollbars=no,personalbar=no,directories=no,left="
							+ file_left
							+ ",top="
							+ file_top
							+ ",height="
							+ file_height + ",width=" + file_width)
	return new_wind;
}

function resizeme(width, height) {
	window.resizeTo(width, height);
	window.moveTo((screen.availWidth - width) / 2,
			(screen.availHeight - height) / 2);
}

function resizefull() {
	var width = screen.availWidth;
	var height = screen.availHeight;
	window.moveTo(0, 0);
	window.resizeTo(width, height);
}

function setColorDoc(id, type) {
	alert(type + "_" + id);
	if (obj = document.getElementById(type + "_" + id)) {
		Obj.style.cursor = 'hand';
		// Obj.bgColor = '#FEE9BE';
		Obj.bgColor = '#fbd1d1';
		Obj.Color = '#ff0000';
	} else {
		alert("no get");
	}
}
var tr_seleccionado;
function mOver(Obj) {
	// if (!Obj.contains(event.fromElement))
	// {
	Obj.style.cursor = 'hand';
	// Obj.bgColor = '#FEE9BE'; if(Obj.bgColor != '#9eddec')
	Obj.bgColor = '#9cceb1';
	Obj.Color = '#ff0000';
	// }
}
function mOverSelect(Obj) {
	Obj.style.cursor = 'hand';
	Obj.bgColor = '#9EDDEC';
	Obj.Color = '#ff0000';
	if (tr_seleccionado != null)
		tr_seleccionado.bgColor = '#FFFFFF';
	if (tr_seleccionado != '#FFFFFF')
		Obj.bgColor = '#9eddec';
	tr_seleccionado = Obj;
}

function mOut(Obj, SetToColor) {
	// if (!Obj.contains(event.toElement))
	// {//tr_seleccionado
	Obj.style.cursor = 'default';
	// if (SetToColor!="")
	if (SetToColor) {
		Obj.bgColor = SetToColor;
	} else {
		if (Obj.bgColor != '#9eddec')
			Obj.bgColor = '#FFFFFF';
	}
	//}
}

/*var cual;
function pinta_tabla(){
	cual=document.getElementById("informacion").rows;

	for(a=0;a<cual.length;a++){
		color(a);
	}

}

function color(b){
	if(b%2==0)
		cual[b].style.backgroundColor="#ff0000";
	else
		cual[b].style.backgroundColor="#0000ff";
}*/